#ifndef SYSTRAY_H
#define SYSTRAY_H

#include <QObject>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include <QDebug>
#include <QTimer>
#include "json/json.h"


using namespace Json;

class Systray : public QObject
{
	Q_OBJECT

	public:
		Systray();
		void addMenuAction(QString actionName);
		void setToolTip(QString tooltip);
		void startAlarmAnim();
		void stopAlarmAnim();
		void setErrorState(bool error);
		void setIcon(QIcon *newIcon);
		void hide();
	private:
                QSystemTrayIcon *trayIcon;
                QMenu *trayIconMenu;
		QTimer *alarmAnimTimer;
		bool flipIconAlarmHelper;
		QIcon systrayNormalIcon;
		QIcon systrayAlertIcon;
		QIcon systrayErrorIcon;

	private slots:
		void handleMenuTrigger(QAction *action);
		void handleIconTrigger(QSystemTrayIcon::ActivationReason reason);
		void flipIconAlarm();

	signals:
		void newAction(QString action);

};

#endif
